package com.pomelo.kill.service.impl;

import com.pomelo.kill.service.OrderService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.pomelo.kill.model.Order;
import com.pomelo.kill.mapper.OrderMapper;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    public int deleteByPrimaryKey(String id) {
        return orderMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Order record) {
        return orderMapper.insert(record);
    }

    @Override
    public int insertSelective(Order record) {
        return orderMapper.insertSelective(record);
    }

    @Override
    public Order selectByPrimaryKey(String id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Order record) {
        return orderMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Order record) {
        return orderMapper.updateByPrimaryKey(record);
    }

    @Override
    public Order selectByUidAndGid(Integer uid, Integer gid) {
        Order order = new Order();
        order.setUid(uid);
        order.setGid(gid);
        List<Order> orders = orderMapper.selectBySelective(order);
        return orders.size() == 0 ? null : orders.get(0);
    }

    @Override
    public List<Order> selectByUid(Integer uid) {
        return orderMapper.selectByUserid(uid);
    }

}
